<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: huajie <banhuajie@163.com>
// +----------------------------------------------------------------------
namespace Admin\Controller;
use Admin\Model\AuthGroupModel;
use COM\Page;
/**
 * 后台内容控制器
 * @author huajie <banhuajie@163.com>
 */

class LeavewordtypeController extends \Admin\Controller\AdminController {
	function index(){
		$Leavewordtype   =   D('Leavewordtype');
		$list = $this->lists($Leavewordtype);
		$this->assign('list',$list);
		$this->display();
	}
	function add(){
		$this->display();
	}
	function edit(){
		$id = I('get.id');
		$data = D('Leavewordtype')->find($id);
		$this->assign('data',$data);
		$this->display();
	}
	function del(){
		$id = I('get.id');
		$res = D('Leavewordtype')->delete($id);
		if($res !== false){
			$this->success('删除留言分类成功！');
		}else{
			$this->error('删除留言分类失败！');
		}
	}
	function save(){
		$data = I();
		if(!isset($data['id'])){
			$data['ctime'] = time();
		}
		$leavewordtype = D('Leavewordtype');
		$res = $leavewordtype->update($data);
        if(!$res){
            $this->error($leavewordtype->getError());
        }else{
            if($res['id']){
                $this->success('添加成功！', U('index'));
            }else{
                $this->success('更新成功！', U('index'));
            }
        }
	}
}
